{ Siberian Olympiad. 3 stage.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/wso/stage3/wso_3stage.pdf
  Problem 5
  Points: 92
}
{$APPTYPE CONSOLE}
uses sysutils;
var k,n,i,j,c,t,cur,tail,head,prev,new,d:longint; bad:boolean; s,nt:string; a:array[1..20] of string; p:array[1..10000000] of string;  r:boolean;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(k,n);
S:='';
r:=false;
for I := 1 to n do readln(a[i]);
c:=k-length(a[1])+1;
head:=1;
tail:=c;
s:=a[1];
for I := 1 to c do begin
    p[i]:='';
    for j := 1 to i-1 do p[i]:=p[i]+'?';
    p[i]:=p[i]+a[1];
    for j := i+length(a[1]) to k do p[i]:=p[i]+'?';
end;
for i := 2 to n do begin
  prev:=tail;
  new:=tail;
  for j := head to tail do begin
    cur:=k-length(a[i])+1;
    for t := 1 to cur do begin
      nt:=p[j];
      bad:=false;
      for d := 1 to length(a[i]) do begin
        if (a[i][d]='?') and (nt[t+d-1]='?') then nt[t+d-1]:='?' else
        if (a[i][d]<>'?') and (nt[t+d-1]='?') then nt[t+d-1]:=a[i][d] else
        if (a[i][d]='?') and (nt[t+d-1]<>'?') then else
        if (a[i][d]<>nt[t+d-1]) then begin
          bad:=true;
          break;
        end;
      end;
      if not bad then begin
        inc(new);
        p[new]:=nt;
      end;
    end;
  end;
  head:=prev+1;
  tail:=new;
end;
if tail>=head then begin
  s:=p[head];
  for I := 1 to length(s) do
    if s[i]='?' then s[i]:='a';
  writeln(s);
end else writeln('IMPOSSIBLE');
end.